package com.example.HaiDLaobackend.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ApiResponse<T> {
	private int code; // 0 ok
	private String message;
	private T data;

	public static <T> ApiResponse<T> ok(T data) {
		return new ApiResponse<>(0, "ok", data);
	}

	public static <T> ApiResponse<T> error(String message) {
		return new ApiResponse<>(-1, message, null);
	}

	public static <T> ApiResponse<T> error(int code, String message) {
		return new ApiResponse<>(code, message, null);
	}
}


